/*
 * @Author: szx
 * @Date: 2021-11-29 14:16:44
 * @LastEditTime: 2021-11-29 14:42:24
 * @Description:
 * @FilePath: \leetcode\1-99\48\48.js
 */
/**
 * @param {number[][]} matrix
 * @return {void} Do not return anything, modify matrix in-place instead.
 */
var rotate = function (matrix) {
    const n = matrix.length;
    if (n == 0 || n == 1) return matrix;
    for (let i = 0; i < n / 2; i++) {
        for (let j = i; j < n - i - 1; j++) {
            console.table(matrix);
            let tmp = matrix[n - j - 1][i];
            matrix[n - j - 1][i] = matrix[n - i - 1][n - j - 1];
            matrix[n - i - 1][n - j - 1] = matrix[j][n - i - 1];
            matrix[j][n - i - 1] = matrix[i][j];
            matrix[i][j] = tmp;
        }
    }
    return matrix;
};
console.table(
    rotate([[1,2],[3,4]])
);
